﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Manul.Genetics.Algorythm
{
    public static class Algorythm
    {
        public static IEnumerable<T> ReturnRandomItems<T>(IEnumerable<T> sourceArray, int max)
        {
            if (sourceArray.Count<T>() <= max)
                return sourceArray.AsEnumerable();
            List<T> sourceArrayClone = sourceArray.ToList();
            Random random = new Random(DateTime.Today.Millisecond);
            int i = 0;
            while (i++ < max)
                sourceArrayClone.RemoveAt(random.Next(sourceArrayClone.Count));
            return sourceArrayClone.AsEnumerable();
        }
    }
}
